package com.wjr.braveheart.http.okhttp;

import java.util.concurrent.TimeUnit;

import okhttp3.OkHttpClient;

/**
 * @Description: OkHttpClient 创建的工具类
 * @Author: 长安三日
 * @Email: 邮箱
 * @CreateDate: 2020/6/6 13:56
 * @UpdateRemark: 更新说明：
 * @Version: 1.0
 * PS: You can change the world with code! Don't give up!
 */
public class OkHttpClientUtils {
    private static OkHttpClient sInstance;

    public static OkHttpClient getOkHttpClient() {
        if (sInstance == null) {
            initClient();
        }
        return sInstance;
    }

    private static void initClient() {
        OkHttpClient.Builder builder = new OkHttpClient.Builder()
                .connectTimeout(60, TimeUnit.SECONDS)
                .writeTimeout(60, TimeUnit.SECONDS)
                .readTimeout(60, TimeUnit.SECONDS);
        builder.followRedirects(true);
        sInstance = builder.build();
    }
}
